package com.doudou.collection.adapter.controller;


import com.doudou.collection.domain.service.UserDetailService;
import com.doudou.collection.infrastructure.common.web.ResultVO;
import com.doudou.collection.orm.vo.UserDetailFansAndFollowVO;
import com.doudou.collection.orm.vo.UserDetailStandardVO;
import com.doudou.collection.orm.vo.UserSimpleVO;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName UserDetailController<br>
 * @Description 个人信息管理模块<br>
 * @Author 王林峰<br>
 * @Date 2023/6/23 15:02<br>
 * @Version 1.0<br>
 */
@Api(tags = "03.用户管理模块")
@Slf4j
@RestController
@RequestMapping("/v1/userdetail")
public class UserDetailController {

    @Autowired
    UserDetailService userDetailService;

    @ApiOperation("个人粉丝数")
    @ApiOperationSupport(order = 400)
    @ApiImplicitParam(name = "id", value = "用户id", dataType = "long")
    @GetMapping("/{id}/fans")
    public ResultVO selectFans(@PathVariable Long id) {
        log.debug("查询当前用户粉丝数, {}", id);
        UserDetailFansAndFollowVO fansCount = userDetailService.selectFansCountById(id);
        return ResultVO.ok(fansCount);
    }

    @ApiOperation("个人粉丝列表")
    @ApiOperationSupport(order = 410)
    @ApiImplicitParam(name = "id", value = "用户id", dataType = "long")
    @GetMapping("/{id}/fanslist")
    public ResultVO selectFansList(@PathVariable Long id) {
        log.debug("查询当前用户粉丝列表, {}", id);
        List<UserSimpleVO> list = userDetailService.selectFansListById(id);
        return ResultVO.ok(list);
    }


    @ApiOperation("个人关注数")
    @ApiOperationSupport(order = 430)
    @ApiImplicitParam(name = "id", value = "用户id", dataType = "long")
    @GetMapping("/{id}/follows")
    public ResultVO selectFollows(@PathVariable Long id) {
        log.debug("查询当前用户关注数, {}", id);
        UserDetailFansAndFollowVO followCount =userDetailService.selectFollowsCountById(id);
        return ResultVO.ok(followCount);
    }

    @ApiOperation("个人关注列表")
    @ApiOperationSupport(order = 440)
    @ApiImplicitParam(name = "id", value = "用户id", dataType = "long")
    @GetMapping("/{id}/followlist")
    public ResultVO selectFollowList(@PathVariable Long id) {
        log.debug("查询当前用户关注列表, {}", id);

        List<UserSimpleVO> list = userDetailService.selectFollowListById(id);
        return ResultVO.ok(list);
    }

    @ApiOperation("个人详细信息")
    @ApiOperationSupport(order = 450)
    @ApiImplicitParam(name = "id", value = "用户id", dataType = "long")
    @GetMapping("/{id}/info")
    public ResultVO getStandardById(@PathVariable Long id) {
        log.debug("开始处理查询【当前用户个人详细信息】请求, {}", id);
        UserDetailStandardVO userInfo = userDetailService.getStandardById(id);
        return ResultVO.ok(userInfo);
    }


}
